package com.second.taobao.topic;

import com.google.gson.Gson;
import com.second.util.HbaseUtils;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.client.Result;

import java.io.IOException;
import java.util.HashMap;

public class GetUserTopic {

    public static void main(String[] args) {
        try {
            Result res = HbaseUtils.get(args[0], args[1]);

            Gson gson =new Gson();
            HashMap<String, Object> map = new HashMap<String, Object>();

            for (Cell rowKV : res.rawCells()) {
                map.put(new String(CellUtil.cloneFamily(rowKV)) + "_" + new String(CellUtil.cloneQualifier(rowKV)), new String(CellUtil.cloneValue(rowKV)));
            }

            String json = gson.toJson(map);
            System.out.println(json);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
